package tuwien.whattowear;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class AdviceActivity extends Activity {

	private Button backBtn;
	private String analysis_result = "";
	private TextView adviceText;
	private ImageView adviceImage;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.advice_layout);
	    
	    backBtn = (Button) findViewById(R.id.buttonReturn);
	    adviceText = (TextView)findViewById(R.id.adviceText);
	    adviceImage = (ImageView)findViewById(R.id.imageViewAdvice);
	    
	    addButtonListeners();
	    
	    analysis_result = this.getIntent().getExtras().getString("analysis_result");
	    //Log.i("info", "RECIEVED RESULT: "+analysis_result);
	    
	    adviceText.setText(getAdvice());
	} 
	
	private void addButtonListeners(){
		backBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0){
				finish();
			}
		});
	}
	
	private String getAdvice(){
		
		if (analysis_result.equals("sunny0")){
			adviceImage.setImageResource(R.drawable.sunny0);
			return "It's sunny outside, wear lighter clothes!";
		} else if (analysis_result.equals("sunny1")){
			adviceImage.setImageResource(R.drawable.sunny1);
			return "It's sunny outside, wear lighter clothes!";
		} else if (analysis_result.equals("sunny2")){
			adviceImage.setImageResource(R.drawable.sunny2);
			return "It's sunny outside, wear lighter clothes!";
		} else if (analysis_result.equals("sunny3")){
			adviceImage.setImageResource(R.drawable.sunny3);
			return "It's sunny outside, wear lighter clothes!";
		} else if (analysis_result.equals("cloudy0")){
			adviceImage.setImageResource(R.drawable.cloudy0);
			return "It's seems to be cloudy, bring a coat and an umbrella!";
		} else if (analysis_result.equals("cloudy1")){
			adviceImage.setImageResource(R.drawable.cloudy1);
			return "It's seems to be cloudy, bring a coat and an umbrella!";
		} else if (analysis_result.equals("cloudy2")){
			adviceImage.setImageResource(R.drawable.cloudy2);
			return "It's seems to be cloudy, bring a coat and an umbrella!";
		} else if (analysis_result.equals("cloudy3")){
			adviceImage.setImageResource(R.drawable.cloudy3);
			return "It's seems to be cloudy, bring a coat and an umbrella!";
		} else if (analysis_result.equals("snowy0")){
			adviceImage.setImageResource(R.drawable.snowy0);
			return "It's seems to be snowing, be careful outside and wear some warmer clothes!";
		} else if (analysis_result.equals("snowy1")){
			adviceImage.setImageResource(R.drawable.snowy1);
			return "It's seems to be snowing, be careful outside and wear some warmer clothes!";
		} else if (analysis_result.equals("snowy2")){
			adviceImage.setImageResource(R.drawable.snowy2);
			return "It's seems to be snowing, be careful outside and wear some warmer clothes!";
		} else if (analysis_result.equals("snowy3")){
			adviceImage.setImageResource(R.drawable.snowy3);
			return "It's seems to be snowing, be careful outside and wear some warmer clothes!";
		} else {
			return "The picture could not be analyzed, please take another one!";
		}
		
		
	}

}
